package cz.muni.fi.pv112.cranesimulator.models;

import cz.muni.fi.pv112.cranesimulator.scene.Scene;
import cz.muni.fi.pv112.cranesimulator.utils.handlers.opengl.DisplayListStorable;

/**
 *
 * @author Michal Ďuriš
 */
public abstract class Model implements DisplayListStorable {

    protected int displayListID;

    protected float[] displacement = {0.0f, 0.0f, 0.0f};

    protected float[] rotation = {0.0f, 0.0f, 0.0f};

    abstract public float[][] getVertexCoords();

    abstract public float[][] getTextureCoords();

    abstract public float[][] getNormalCoords();

    public void moveTo(float x, float y, float z) {
        displacement[Scene.X_AXIS] = x;
        displacement[Scene.Y_AXIS] = y;
        displacement[Scene.Z_AXIS] = z;
    }

    public void moveBy(float x, float y, float z) {
        displacement[Scene.X_AXIS] += x;
        displacement[Scene.Y_AXIS] += y;
        displacement[Scene.Z_AXIS] += z;
    }

    public float[] getDisplacement() {
        return displacement;
    }

    public void rotateTo(float angleX, float angleY, float angleZ) {
        rotation[Scene.X_AXIS] = angleX;
        rotation[Scene.Y_AXIS] = angleY;
        rotation[Scene.Z_AXIS] = angleZ;
    }

    public void rotateBy(float angleX, float angleY, float angleZ) {
        rotation[Scene.X_AXIS] += angleX;
        rotation[Scene.Y_AXIS] += angleY;
        rotation[Scene.Z_AXIS] += angleZ;
    }

    public float[] getRotation() {
        return rotation;
    }

    @Override
    public int getDisplayListID() {
        return displayListID;
    }

    @Override
    public void setDisplayListID(int displayListID) {
        this.displayListID = displayListID;
    }

    @Override
    public String toString() {
        return "Model{" + "displacement = " + displacement[Scene.X_AXIS] + ", "
                + displacement[Scene.Y_AXIS] + ", " + displacement[Scene.Z_AXIS]
                + ", rotation = " + rotation[Scene.Y_AXIS] + '}';
    }

}
